package br.com.social.mobile.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Util {

	public static Integer nullToZero(Integer param) {
		if (param == null) {
			return 0;
		} else {
			return param;
		}
	}
	
	public static Long nullToZero(Long param) {
		if (param == null) {
			return 0l;
		} else {
			return param;
		}
	}	

	public static String trim(String param) {
		if (param != null) {
			return param.trim();
		} else {
			return param;
		}
	}

	public static Date addDays(Date dtDate, int numDays) {
		Calendar c = Calendar.getInstance();
		c.setTime(dtDate);
		c.add(Calendar.DATE, numDays);
		return c.getTime();
	}
	
	
	public static String formatDateHour(Date date) {
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
		return sdf.format(date);
	}
	
	public static Date timeZone(Date date, int timeZone) {
		Calendar c = Calendar.getInstance();
		c.setTime(date);
		c.add(Calendar.HOUR_OF_DAY, timeZone);
		return c.getTime();
	}
	
}